#
# SPIM S20 MIPS Simulator.
# Makefile for SPIM.
# Copyright (C) 1990-1992 by James Larus (larus@cs.wisc.edu).
# ALL RIGHTS RESERVED.
#
# SPIM is distributed under the following conditions:
#
#   You may make copies of SPIM for your own use and modify those copies.
#
#   All copies of SPIM must retain my name and copyright notice.
#
#   You may not sell SPIM or distributed SPIM in conjunction with a commerical
#   product or service without the expressed written consent of James Larus.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
#
# $Header: /home/primost/larus/Software/SPIM/RCS/Makefile.std,v 3.35 1994/01/02 21:04:50 larus Exp $


#
# To make spim, type:
#
#   make spim
#
# To make xpsim, type:
#
#   make xspim
#

#
# To verify spim works, type:
#
#   make test
#

#
# To make cl-spim (cycle level SPIM simulator), type:
#
#   make cl-spim
#
# To make cl-xpsim, type:
#
#   make cl-xspim
#


#
# The following parameters must be set for the target machine:
#
# Note: SPIM does not work when compiled by a compiler that does not
# distinguish floats from doubles (e.g., pcc and pcc-compatible compilers
# on the VAX).
#


# Full path for directory containing X11 include files:
X_INCLUDE_DIR=/usr/misc/X11/include


# Location of X11 root directory.
TOPDIR = /usr/misc/X11


# Full path for directory that will hold the trap handler file:
TRAP_DIR = /var/scratch/lib

# Full path for the directory that will hold the executable files:
BIN_DIR = /var/scratch/bin.MIPS

# Full path for the directory that will hold the man files:
MAN_DIR = /var/scratch/man


# Full path for the trap handler file:
TRAP_PATH = \"$(TRAP_DIR)/trap.handler\"

# If you have flex, use it instead of lex.  If you use flex, define this
# variable and set LEXFLAGS.
MYLEX = flex

# SPIM needs flex's -I flag since the scanner is used interactively.
# You can set the -8 flag so that funny characters do not hang the scanner.
LEXFLAGS = -I -8


# If you use lex, set the variables this way:
#MYLEX = lex
#LEXFLAGS =


# Size of the segments when spim starts up (data segment must be >= 64K).
# (These sizes are fine for most users since SPIM dynamically expands
# the memory as necessary.)
MEM_SIZES = -DTEXT_SIZE=65536 -DDATA_SIZE=131072 -DK_TEXT_SIZE=65536


#
# End of parameters
#


CC = cc
IFLAGS = -I$(X_INCLUDE_DIR)
CL_FLAG =
CFLAGS = -g $(IFLAGS) $(ENDIAN) $(MEM_SIZES) $(EXTRA_C_FLAGS) $(CL_FLAG)
YFLAGS = -d
YCFLAGS =
LDFLAGS = -lm
XLDFLAGS = -L$(TOPDIR)/lib -lXaw -lXmu -lXt -lXext -lX11


# lex.yy.c is usually compiled with -O to speed it up.

LEXCFLAGS = -O



OBJS = spim-utils.o run.o mem.o inst.o data.o sym-tbl.o y.tab.o lex.yy.o \
       read-aout.o mips-syscall.o


XOBJS = windows.o buttons.o


CLOBJS = cl-cache.o cl-except.o cl-tlb.o cl-cycle.o

ENDIAN=`cat configuration`


spim:   force
	@if [ -f .cl-spim-made ]; then make -f Makefile.std clean; else true; fi
	@touch .spim-made
	make -f Makefile.std spim2

spim2:	$(OBJS) spim.o
	$(CC) -g $(OBJS) spim.o $(LDFLAGS) -o spim -lm


xspim:  force
	@if [ -f .cl-spim-made ]; then make -f Makefile.std clean; else true; fi
	@touch .spim-made
	make -f Makefile.std xspim2

xspim2:	$(OBJS) $(XOBJS) xspim.o
	$(CC) -g $(OBJS) $(XOBJS) xspim.o $(LDFLAGS) $(XLDFLAGS) -o xspim -lm


cl-spim: force
	@if [ -f .spim-made ]; then make -f Makefile.std clean; else true; fi
	@touch .cl-spim-made
	make -f Makefile.std cl-spim2 CL_FLAG=-DCL_SPIM

cl-spim2: $(OBJS) $(CLOBJS) spim.o
	$(CC) -g $(OBJS) $(CLOBJS) spim.o $(LDFLAGS) -o cl-spim -lm


cl-xspim: force
	@if [ -f .spim-made ]; then make -f Makefile.std clean; else true; fi
	@touch .cl-spim-made
	make -f Makefile.std cl-xspim2 CL_FLAG=-DCL_SPIM

cl-xspim2: $(OBJS) $(CLOBJS) $(XOBJS) xspim.o
	$(CC) -g $(OBJS) $(CLOBJS) $(XOBJS) xspim.o $(LDFLAGS) $(XLDFLAGS) -o cl-xspim -lm


force:	configuration

configuration:
	Configure

#

#
# Test spim with a torture test:
#

test:	spim
	/bin/rm -f Tests/tt.out
	@echo
	csh -c "./spim -bare -notrap -file Tests/tt.bare.s >& Tests/tt.out"
	@echo The next command should not produce any output:
	diff Tests/tt.out Tests/tt.bare.OK
	/bin/rm -f Tests/tt.out

	@echo
	@if [ ! -f $(TRAP_DIR)/trap.handler ]; then echo "Trap Handler not installed; do make install"; exit 1; else true; fi
	csh -c "./spim -file Tests/tt.s < Tests/tt.in >& Tests/tt.out"
	@echo The next command should not produce any output:
	diff Tests/tt.out Tests/tt.OK
	@echo
	/bin/rm -f Tests/tt.out


# This test currently only works for little-endian machines.  The file
# tt.alu.bare.s needs to be converted in places for big-endian machines.

test_bare:
	csh -c "./spim -bare -notrap -file Tests/tt.alu.bare.s >& Tests/tt.out"
	@echo The next command should not produce any output:
	diff Tests/tt.out Tests/tt.alu.bare.OK
	/bin/rm -f Tests/tt.out

	@echo
	csh -c "./spim -bare -notrap -file Tests/tt.fpu.bare.s >& Tests/tt.out"
	@echo The next command should not produce any output:
	diff Tests/tt.out Tests/tt.fpu.bare.OK
	/bin/rm -f Tests/tt.out

#

TAGS:	*.c *.h *.l *.y
	etags *.l *.y *.c *.h


clean:
	rm -f spim xspim cl-spim cl-xspim *.o y.output core a.out TAGS \
	  .spim-made .cl-spim-made \
	  spim.tar.* spim.aux spim.log spim.dvi spim.shar*

install: spim xspim
	install -c -s  spim $(BIN_DIR)
	install -c -s  xspim $(BIN_DIR)
	install -c -m 0444 trap.handler $(TRAP_DIR)
	install -c -m 0444 spim.man $(MAN_DIR)
	install -c -m 0444 xspim.man $(MAN_DIR)

very-clean: clean
	rm -f y.tab.h y.tab.c lex.yy.c spim.tar* Documentation/spim.ps


SRC = spim-utils.c run.c mem.c inst.c data.c sym-tbl.c y.tab.o lex.yy.o \
       read-aout.c mips-syscall.c

XSRC = windows.c buttons.c


#
# Dependences not handled well by makedepend:
#

spim-utils.o: spim-utils.c spim.h inst.h mem.h reg.h y.tab.h VERSION
	$(CC) $(IFLAGS) $(CFLAGS) -DDEFAULT_TRAP_HANDLER=$(TRAP_PATH) -DSPIM_VERSION="\"`cat VERSION`\"" -c spim-utils.c


y.tab.h: y.tab.c

y.tab.c: parser.y
	yacc $(YFLAGS) parser.y

y.tab.o: y.tab.c
	$(CC) $(IFLAGS) $(CFLAGS) $(YCFLAGS) -c y.tab.c


lex.yy.c: scanner.l
	$(MYLEX) $(LEXFLAGS) scanner.l

lex.yy.o: lex.yy.c
	$(CC) $(IFLAGS) $(LEXCFLAGS) -c lex.yy.c


#
# DO NOT DELETE THIS LINE -- make depend depends on it.

buttons.o: /usr/include/X11/Intrinsic.h
buttons.o: /usr/include/X11/Xlib.h
buttons.o: /usr/include/sys/types.h
buttons.o: /usr/include/sys/ansi_compat.h
buttons.o: /usr/include/X11/X.h
buttons.o: /usr/include/X11/Xfuncproto.h
buttons.o: /usr/include/X11/Xosdefs.h
buttons.o: /usr/include/stddef.h
buttons.o: /usr/include/X11/Xutil.h
buttons.o: /usr/include/X11/Xresource.h
buttons.o: /usr/include/string.h
buttons.o: /usr/include/X11/Core.h
buttons.o: /usr/include/X11/Composite.h
buttons.o: /usr/include/X11/Constraint.h
buttons.o: /usr/include/X11/Object.h
buttons.o: /usr/include/X11/RectObj.h
buttons.o: /usr/include/X11/StringDefs.h
buttons.o: /usr/include/X11/Shell.h
buttons.o: /usr/include/X11/Xaw/Form.h
buttons.o: /usr/include/X11/Xaw/AsciiText.h
buttons.o: /usr/include/X11/Xaw/Text.h
buttons.o: /usr/include/X11/Xaw/TextSink.h
buttons.o: /usr/include/X11/Xaw/TextSrc.h
buttons.o: /usr/include/X11/Xaw/AsciiSrc.h
buttons.o: /usr/include/X11/Xaw/AsciiSink.h
buttons.o: /usr/include/X11/Xaw/Command.h
buttons.o: /usr/include/X11/Xaw/Label.h
buttons.o: /usr/include/X11/Xaw/Simple.h
buttons.o: /usr/include/X11/Xmu/Converters.h
buttons.o: /usr/include/X11/Xaw/Dialog.h
buttons.o: /usr/include/X11/Xaw/MenuButton.h
buttons.o: /usr/include/X11/Xaw/SimpleMenu.h
buttons.o: /usr/include/X11/Xaw/Sme.h
buttons.o: /usr/include/X11/Xaw/SmeBSB.h
buttons.o: /usr/include/X11/Xaw/Cardinals.h
buttons.o: /usr/include/stdio.h
buttons.o: /usr/include/setjmp.h
buttons.o: /usr/include/ctype.h
buttons.o: spim.h
buttons.o: spim-utils.h
buttons.o: xspim.h
buttons.o: inst.h
buttons.o: mem.h
buttons.o: reg.h
buttons.o: scanner.h
buttons.o: sym-tbl.h
buttons.o: buttons.h
cl-cache.o: /usr/include/stdio.h
cl-cache.o: /usr/include/sys/ansi_compat.h
cl-cache.o: /usr/include/setjmp.h
cl-cache.o: spim.h
cl-cache.o: inst.h
cl-cache.o: mem.h
cl-cache.o: mips-syscall.h
cl-cache.o: cl-cache.h
cl-cache.o: cl-mem.h
cl-cache.o: cl-tlb.h
cl-cycle.o: /usr/include/nan.h
cl-cycle.o: /usr/include/sys/ansi_compat.h
cl-cycle.o: /usr/include/math.h
cl-cycle.o: /usr/include/stdio.h
cl-cycle.o: /usr/include/X11/Intrinsic.h
cl-cycle.o: /usr/include/X11/Xlib.h
cl-cycle.o: /usr/include/sys/types.h
cl-cycle.o: /usr/include/X11/X.h
cl-cycle.o: /usr/include/X11/Xfuncproto.h
cl-cycle.o: /usr/include/X11/Xosdefs.h
cl-cycle.o: /usr/include/stddef.h
cl-cycle.o: /usr/include/X11/Xutil.h
cl-cycle.o: /usr/include/X11/Xresource.h
cl-cycle.o: /usr/include/string.h
cl-cycle.o: /usr/include/X11/Core.h
cl-cycle.o: /usr/include/X11/Composite.h
cl-cycle.o: /usr/include/X11/Constraint.h
cl-cycle.o: /usr/include/X11/Object.h
cl-cycle.o: /usr/include/X11/RectObj.h
cl-cycle.o: /usr/include/X11/StringDefs.h
cl-cycle.o: spim.h
cl-cycle.o: inst.h
cl-cycle.o: reg.h
cl-cycle.o: mem.h
cl-cycle.o: read-aout.h
cl-cycle.o: spim-utils.h
cl-cycle.o: sym-tbl.h
cl-cycle.o: y.tab.h
cl-cycle.o: mips-syscall.h
cl-cycle.o: cl-mem.h
cl-cycle.o: cl-cache.h
cl-cycle.o: cl-cycle.h
cl-cycle.o: cl-tlb.h
cl-cycle.o: cl-except.h
cl-cycle.o: /usr/include/syscall.h
cl-cycle.o: /usr/include/signal.h
cl-except.o: /usr/include/math.h
cl-except.o: /usr/include/stdio.h
cl-except.o: /usr/include/sys/ansi_compat.h
cl-except.o: /usr/include/setjmp.h
cl-except.o: spim.h
cl-except.o: inst.h
cl-except.o: reg.h
cl-except.o: mem.h
cl-except.o: spim-utils.h
cl-except.o: y.tab.h
cl-except.o: mips-syscall.h
cl-except.o: cl-mem.h
cl-except.o: cl-cycle.h
cl-except.o: cl-cache.h
cl-except.o: cl-except.h
cl-except.o: /usr/include/syscall.h
cl-except.o: /usr/include/signal.h
cl-except.o: cl-tlb.h
cl-tlb.o: spim.h
cl-tlb.o: inst.h
cl-tlb.o: reg.h
cl-tlb.o: mem.h
cl-tlb.o: mips-syscall.h
cl-tlb.o: cl-mem.h
cl-tlb.o: cl-tlb.h
data.o: spim.h
data.o: spim-utils.h
data.o: inst.h
data.o: mem.h
data.o: reg.h
data.o: sym-tbl.h
data.o: parser.h
data.o: run.h
data.o: read-aout.h
data.o: data.h
inst.o: /usr/include/stdio.h
inst.o: /usr/include/sys/ansi_compat.h
inst.o: /usr/include/string.h
inst.o: spim.h
inst.o: spim-utils.h
inst.o: inst.h
inst.o: mem.h
inst.o: reg.h
inst.o: sym-tbl.h
inst.o: y.tab.h
inst.o: parser.h
inst.o: scanner.h
inst.o: data.h
inst.o: op.h
lex.yy.o: /usr/include/stdio.h
lex.yy.o: /usr/include/sys/ansi_compat.h
lex.yy.o: spim.h
lex.yy.o: spim-utils.h
lex.yy.o: inst.h
lex.yy.o: sym-tbl.h
lex.yy.o: y.tab.h
lex.yy.o: parser.h
lex.yy.o: scanner.h
lex.yy.o: op.h
mem.o: spim.h
mem.o: spim-utils.h
mem.o: inst.h
mem.o: mem.h
mem.o: reg.h
mips-syscall.o: /usr/include/stdio.h
mips-syscall.o: /usr/include/sys/ansi_compat.h
mips-syscall.o: /usr/include/sys/types.h
mips-syscall.o: /usr/include/signal.h
mips-syscall.o: /usr/include/syscall.h
mips-syscall.o: /usr/include/limits.h
mips-syscall.o: spim.h
mips-syscall.o: inst.h
mips-syscall.o: mem.h
mips-syscall.o: reg.h
mips-syscall.o: read-aout.h
mips-syscall.o: sym-tbl.h
mips-syscall.o: spim-syscall.h
mips-syscall.o: mips-syscall.h
read-aout.o: /usr/include/a.out.h
read-aout.o: /usr/include/sys/ansi_compat.h
read-aout.o: /usr/include/stdio.h
read-aout.o: /usr/include/ldfcn.h
read-aout.o: spim.h
read-aout.o: spim-utils.h
read-aout.o: inst.h
read-aout.o: mem.h
read-aout.o: data.h
read-aout.o: parser.h
read-aout.o: read-aout.h
read-aout.o: sym-tbl.h
run.o: /usr/include/nan.h
run.o: /usr/include/sys/ansi_compat.h
run.o: /usr/include/math.h
run.o: /usr/include/stdio.h
run.o: spim.h
run.o: spim-utils.h
run.o: inst.h
run.o: mem.h
run.o: reg.h
run.o: sym-tbl.h
run.o: y.tab.h
run.o: read-aout.h
run.o: mips-syscall.h
run.o: run.h
spim-utils.o: /usr/include/stdio.h
spim-utils.o: /usr/include/sys/ansi_compat.h
spim-utils.o: /usr/include/ctype.h
spim-utils.o: /usr/include/string.h
spim-utils.o: /usr/include/varargs.h
spim-utils.o: spim.h
spim-utils.o: spim-utils.h
spim-utils.o: inst.h
spim-utils.o: data.h
spim-utils.o: mem.h
spim-utils.o: reg.h
spim-utils.o: scanner.h
spim-utils.o: parser.h
spim-utils.o: y.tab.h
spim-utils.o: run.h
spim-utils.o: sym-tbl.h
spim-utils.o: /usr/include/sys/exec.h
spim.o: /usr/include/stdio.h
spim.o: /usr/include/sys/ansi_compat.h
spim.o: /usr/include/ctype.h
spim.o: /usr/include/setjmp.h
spim.o: /usr/include/signal.h
spim.o: /usr/include/sys/types.h
spim.o: /usr/include/sys/time.h
spim.o: /usr/include/sys/ioctl.h
spim.o: /usr/include/sys/ttydev.h
spim.o: /usr/include/sgtty.h
spim.o: /usr/include/varargs.h
spim.o: spim.h
spim.o: spim-utils.h
spim.o: inst.h
spim.o: mem.h
spim.o: reg.h
spim.o: parser.h
spim.o: read-aout.h
spim.o: sym-tbl.h
spim.o: scanner.h
spim.o: y.tab.h
sym-tbl.o: spim.h
sym-tbl.o: spim-utils.h
sym-tbl.o: inst.h
sym-tbl.o: mem.h
sym-tbl.o: data.h
sym-tbl.o: parser.h
sym-tbl.o: sym-tbl.h
windows.o: /usr/include/X11/Intrinsic.h
windows.o: /usr/include/X11/Xlib.h
windows.o: /usr/include/sys/types.h
windows.o: /usr/include/sys/ansi_compat.h
windows.o: /usr/include/X11/X.h
windows.o: /usr/include/X11/Xfuncproto.h
windows.o: /usr/include/X11/Xosdefs.h
windows.o: /usr/include/stddef.h
windows.o: /usr/include/X11/Xutil.h
windows.o: /usr/include/X11/Xresource.h
windows.o: /usr/include/string.h
windows.o: /usr/include/X11/Core.h
windows.o: /usr/include/X11/Composite.h
windows.o: /usr/include/X11/Constraint.h
windows.o: /usr/include/X11/Object.h
windows.o: /usr/include/X11/RectObj.h
windows.o: /usr/include/X11/StringDefs.h
windows.o: /usr/include/X11/Xaw/Cardinals.h
windows.o: /usr/include/X11/Xaw/Paned.h
windows.o: /usr/include/X11/Xmu/Converters.h
windows.o: /usr/include/X11/Xaw/AsciiText.h
windows.o: /usr/include/X11/Xaw/Text.h
windows.o: /usr/include/X11/Xaw/TextSink.h
windows.o: /usr/include/X11/Xaw/TextSrc.h
windows.o: /usr/include/X11/Xaw/AsciiSrc.h
windows.o: /usr/include/X11/Xaw/AsciiSink.h
windows.o: /usr/include/X11/Xaw/Box.h
windows.o: /usr/include/X11/Xaw/Label.h
windows.o: /usr/include/X11/Xaw/Simple.h
windows.o: /usr/include/stdio.h
windows.o: spim.h
windows.o: spim-utils.h
windows.o: buttons.h
windows.o: xspim.h
windows.o: windows.h
xspim.o: /usr/include/stdio.h
xspim.o: /usr/include/sys/ansi_compat.h
xspim.o: /usr/include/setjmp.h
xspim.o: /usr/include/varargs.h
xspim.o: /usr/include/X11/Intrinsic.h
xspim.o: /usr/include/X11/Xlib.h
xspim.o: /usr/include/sys/types.h
xspim.o: /usr/include/X11/X.h
xspim.o: /usr/include/X11/Xfuncproto.h
xspim.o: /usr/include/X11/Xosdefs.h
xspim.o: /usr/include/stddef.h
xspim.o: /usr/include/X11/Xutil.h
xspim.o: /usr/include/X11/Xresource.h
xspim.o: /usr/include/string.h
xspim.o: /usr/include/X11/Core.h
xspim.o: /usr/include/X11/Composite.h
xspim.o: /usr/include/X11/Constraint.h
xspim.o: /usr/include/X11/Object.h
xspim.o: /usr/include/X11/RectObj.h
xspim.o: /usr/include/X11/StringDefs.h
xspim.o: /usr/include/X11/Shell.h
xspim.o: /usr/include/X11/Xaw/Cardinals.h
xspim.o: /usr/include/X11/Xaw/Paned.h
xspim.o: /usr/include/X11/Xmu/Converters.h
xspim.o: /usr/include/X11/Xaw/AsciiText.h
xspim.o: /usr/include/X11/Xaw/Text.h
xspim.o: /usr/include/X11/Xaw/TextSink.h
xspim.o: /usr/include/X11/Xaw/TextSrc.h
xspim.o: /usr/include/X11/Xaw/AsciiSrc.h
xspim.o: /usr/include/X11/Xaw/AsciiSink.h
xspim.o: /usr/include/X11/Xaw/Dialog.h
xspim.o: /usr/include/X11/Xaw/Form.h
xspim.o: /usr/include/X11/keysym.h
xspim.o: /usr/include/X11/keysymdef.h
xspim.o: spim.h
xspim.o: spim-utils.h
xspim.o: inst.h
xspim.o: mem.h
xspim.o: reg.h
xspim.o: y.tab.h
xspim.o: buttons.h
xspim.o: windows.h
xspim.o: read-aout.h
xspim.o: xspim.h
y.tab.o: /usr/include/stdio.h
y.tab.o: /usr/include/sys/ansi_compat.h
y.tab.o: spim.h
y.tab.o: spim-utils.h
y.tab.o: inst.h
y.tab.o: mem.h
y.tab.o: reg.h
y.tab.o: sym-tbl.h
y.tab.o: data.h
y.tab.o: scanner.h
y.tab.o: parser.h
parser.o: /usr/include/stdio.h
parser.o: /usr/include/sys/ansi_compat.h
parser.o: spim.h
parser.o: spim-utils.h
parser.o: inst.h
parser.o: mem.h
parser.o: reg.h
parser.o: sym-tbl.h
parser.o: data.h
parser.o: scanner.h
parser.o: parser.h
scanner.o: spim.h
scanner.o: spim-utils.h
scanner.o: inst.h
scanner.o: sym-tbl.h
scanner.o: y.tab.h
scanner.o: parser.h
scanner.o: scanner.h
scanner.o: op.h
